package object3D;

import geometry3D.Point3D;
import context.*;

import javax.media.j3d.Appearance;
import javax.media.j3d.Group;


// ********************************************************************
// *** CLASS: Object3D
// ********************************************************************
public abstract class Object3D implements Context.Constants
{ //private static final boolean DEBUG=true; // Overriding Context.Constants.DEBUG
  protected String ident;
  public Point3D p0; // Lower back corner in 3D coordinate space
  public double width;  // Width  along x-axis
  public double height; // Height along y-axis
  public double depth;  // Depth  along z-axis;

  
  // ******************************************************************
  // *** CONSTRUCTOR
  // ******************************************************************
  public Object3D(String ident,Point3D p0,double width,double height,double depth)
  { this.ident=ident;
    this.p0=p0;
    this.width=width;
    this.height=height;
    this.depth=depth;
//    if(DEBUG) Debug.println("new "+this);
//  Debug.ASSERT(width>0,"");
//  Debug.ASSERT(height>0,"");
//  Debug.ASSERT(depth>0,"");
  }

  // ***************************************************************************
  // *** METHOD: getModel3D
  // ***************************************************************************
  public /*abstract*/ Group getModel3D(Appearance appearance)
  {
    return(null);
  }

  public String toString()
  { return(classID()+"["+ident
      +", p0=(x="+p0.x+",y="+p0.y+",z="+p0.z
      +"), width="+width+", height="+height+", depth="+depth+"]");
  }

  private String classID()
  {
    String id=this.getClass().getName();
    int i=id.lastIndexOf('.');
    if(i>0) id=id.substring(i+1);
    return(id);
  }

}